<?php

namespace App\Models\Scopes;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;

class ActiveScope implements Scope
{
    public function __construct(public string $column = 'show')
    {
        //
    }

    /**
     * 全局作用域，仅展示激活状态的
     */
    public function apply(Builder $builder, Model $model): void
    {
        $builder->where($this->column, true);
    }
}
